import Vue from 'vue'
import Vuex from 'vuex'
import router from './router'

import { Toast } from 'vant';
Vue.use(Toast);




Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      city:"北京"
  },
  mutations: {
      changeCity(state,city){
          state.city = city
            Toast.success('城市选择成功！');
            
      }
  },
  actions: {

      gotoHome( context,city ){
          //调用mutation 的方法，然后传参方式为 在方法之后逗号一个再传递参数
        context.commit("changeCity",city)

          setTimeout(() => {
             router.push({path:'/home'}) 
          }, 1500);
          
      }


  }
})
